{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-header">编辑数据</div>
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">* 用户名</label>
                <div class="layui-input-inline">
                    <input type="text" disabled="" value="{$data.username|default=''}" autocomplete="off" placeholder="请输入用户名" lay-verify="required" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">用户名暂不可修改，如需修改请联系官方</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">* 用户昵称</label>
                <div class="layui-input-inline">
                    <input type="text" name="realname" value="{$data.realname|default=''}" autocomplete="off" placeholder="" lay-verify="required" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">用户昵称</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">* 手机号</label>
                <div class="layui-input-inline">
                    <input type="text" name="mobile" id="mobile" value="{$data.mobile|default=''}" autocomplete="off" placeholder="请输入手机号" lay-verify="phone|number" class="layui-input">
                </div>
                <!--div class="layui-inline">
                    <input id="code1" type="text" name="code" class="layui-input" autocomplete="off" placeholder="短信验证码"  style="width: 100px;"/>
                </div>
                <div class="layui-inline">
                    <input id="btnSendCode1" type="button" class="layui-btn layui-btn-warm verifyImg" value="获取验证码" onClick="sendMessage1()"/>
                </div-->
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">* E-mail</label>
                <div class="layui-input-inline">
                    <input type="text" name="email" id="email" value="{$data.email|default=''}" autocomplete="off" placeholder="请输入E-mail" class="layui-input">
                </div>
            </div>
            
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="*" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="__LIBS__/layui/layui.all.js"></script>
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/layui.base.js"></script>
<script type="text/javascript">
        var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;//手机号正则 
        var count = 60; //间隔函数，1秒执行
        var InterValObj1; //timer变量，控制时间
        var curCount1;//当前剩余秒数
        /*第一*/
        function sendMessage1() {
                curCount1 = count;		 		 
                var phone = $.trim($('#mobile').val());
                if (!phoneReg.test(phone)) {
                        alert(" 请输入有效的手机号码"); 
                        return false;
                }
                $.ajax({
                    type: "POST",      //data 传送数据类型。post 传递
                    dataType: 'json',  // 返回数据的数据类型json
                    url: "/user/index/captcha_sms",  // yii 控制器/方法
                    cache: false,      
                    data: {mobile: phone},  //传送的数据
                    error:function(){
                       alert("数据传输错误");
                    },success: function (data) {
                        if(window.console){
                            console.log(data);
                        }else{
                            console.log(data);
                        }
                    }
                });      

                //设置button效果，开始计时
                $("#btnSendCode1").attr("disabled", "true");
                $("#btnSendCode1").val( + curCount1 + "秒再获取");
                InterValObj1 = window.setInterval(SetRemainTime1, 1000); //启动计时器，1秒执行一次
                //向后台发送处理数据

        }
        function SetRemainTime1() {
                if (curCount1 == 0) {                
                        window.clearInterval(InterValObj1);//停止计时器
                        $("#btnSendCode1").removeAttr("disabled");//启用按钮
                        $("#btnSendCode1").val("重新发送");
                }
                else {
                        curCount1--;
                        $("#btnSendCode1").val( + curCount1 + "秒再获取");
                }
        } 

        /*提交*/
        function binding(){
                alert(1)
        }
</script>
{/block}
